package com.goods.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 商品编码工具类
 * @author huangyanzhong
 * @date 2020-04-01
 */
public class GoodsNoUtil {

    /**
     * 生成商品编码
     * @return
     */
    public static String getGoodsNo() {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String newDate=sdf.format(new Date());
        String result="";
        Random random=new Random();
        //取随机数
        for(int i=0;i<3;i++){
            result+=random.nextInt(10);
        }
        return "GOODS_"+newDate+"_"+result;
    }

}
